home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Editing / Emacs_Next_Line.bsh next >
Encoding:
Text File  |  2004-08-29  |  1.3 KB  |  44 lines

  1. /*
  2.  * Emacs_Next_Line.bsh - Beanshell macro for jEdit that provides
  3.  * 'Emacs-like scrolling.  If the caret is at the bottom of the 
  4.  * screen the next line is centered on the screen rather than 
  5.  * scrolling the whole text area by one line.  For machines with
  6.  * slow painting, this can increase scrolling speed.
  7.  *
  8.  * Copyright (C) 2002-2004, Ollie Rutherfurd <oliver@rutherfurd.net>
  9.  *
  10.  * $Id: Emacs_Next_Line.bsh,v 1.1 2004/03/19 15:57:59 spestov Exp $
  11.  */
  12.  
  13. void emacsNextLine(View view){
  14.  
  15.     // need access to textArea.lastLinePartial
  16.     setAccessibility(true);
  17.  
  18.     int first = textArea.getFirstLine();
  19.     int caretLine = textArea.getScreenLineOfOffset(textArea.getCaretPosition());
  20.     int visibleLines = textArea.getVisibleLines();
  21.     int electricScroll = textArea.getElectricScroll();
  22.  
  23.     if(caretLine != -1 && caretLine+1 >= 
  24.             (visibleLines - (electricScroll + (textArea.lastLinePartial ? 1 : 0))))
  25.     {
  26.         int newFirst = (first + (visibleLines - electricScroll) / 2);
  27.         textArea.setFirstLine(newFirst);
  28.     }
  29.     textArea.goToNextLine(false);
  30. }
  31.  
  32. emacsNextLine(view);
  33.  
  34. /*
  35.     <listitem>
  36.         <para><filename>Emacs_Next_Line.bsh</filename></para>
  37.         <abstract><para>
  38.             Moves the cursor to the next line, centering 
  39.             the current line in the middle of the text area
  40.             if the cursor is at the bottom of the text area.
  41.         </para></abstract>
  42.     </listitem>
  43. */
  44.